<%@ include file="/common/taglibs.jsp"%>
<%@ taglib prefix="catalog" tagdir="/WEB-INF/tags/catalog"%>
<%@ taglib prefix="product" tagdir="/WEB-INF/tags/product"%>
<%@ taglib prefix="customer" tagdir="/WEB-INF/tags/customer"%>
<%@ page language="java" pageEncoding="UTF-8"%>	

<title><fmt:message key="stockNotify.sign" />-${empty product.title?product.productName:product.title}</title>
<meta name="keywords" content="${not empty product.metaKeyword?product.metaKeyword:product.keywords}" />
<meta name="description" content="${not empty product.metaDescription?product.metaDescription:product.productDescription.shortDescription}" />

<form name="stockNotifyForm" id="stockNotifyForm">
	<div class="wrap_12">
		<div class="top"><span><fmt:message key="stockNotify.sign"/></span></div>
		<div class="content">
			<div class="list_prod_02 clearfix">
				<ul class="row">
					
					<li>
						<div class="img">
							<product:productImage product="${product}" sizeType="s1"/>
						</div>
						<div class="name">
							<h4><product:productName product="${product}"/></h4>
							<p>${product.productDescription.shortDescription}</p>
						</div>
						<div class="info">
							<product:productPrice productSku="${product.defaultProductSku}" multiple="true" hasPriceName="true"/>
							<div class="rank">
								<fmt:formatNumber var="score" value="${product.productStat.reviewScore}" pattern="0.0"/>
								<customer:scoreStar value="${score}"/>
								<span>
									<a href="<customer:productReviewUrl product="${product}"/>" target="_blank">
										<fmt:message key="productDetail.onshowReviewCount.title">
											<fmt:param>${product.productStat.onShowReviewCount}</fmt:param>
										</fmt:message>
									</a>
								</span>
							</div>
						</div>
					</li>
										
				</ul>
			</div>
			<div class="block1">
				<table width="100%" border="0" cellspacing="0" cellpadding="0" class="t1">
						<tr>
								<th width="15%"><fmt:message key="stockNotify.customerName"/>(<span class="red">*</span>):</th>
								<td><input id="customerName" name="customerName" value="${customer.fullName}" type="text" class="inputtxt2" style="width:200px" /></td>
						</tr>
						<tr>
								<th><fmt:message key="stockNotify.email"/>(<span class="red">*</span>):</th>
								<td><input id="email" name="email" value="${customer.email}" type="text" class="inputtxt2" style="width:200px" /></td>
						</tr>
						<tr>
								<th><fmt:message key="stockNotify.memo"/>(<span class="red">*</span>):</th>
								<td>
									<div class="inFieldLabel">
										<p>
											<label for="memo"><fmt:message key="stockNotify.memo.tip" /></label>
											<textarea id="memo"  name="memo" cols="" rows="5" class="textareatxt2" style="width:400px"></textarea>
										</p>
									</div>
								</td>
						</tr>
						<tr>
								<th>&nbsp;</th>
								<td>
									
									<input type="hidden" name="doAction" value="add"/>
									<input type="hidden" name="productId" value="${product.productId}"/>
									<a href="javascript:void(0)" id="commitButton" onclick="addStockNotify()"><img src="${txtImagePath}/btn_submit_02.gif" alt="search"/></a>
								</td>
						</tr>
				</table>
			</div>
		</div>
	</div>
</form>	

<input id="url" type="hidden" value="<product:productUrl product="${product}"/>"/>

<c:set var="probizJs_validation" value="true" scope="request"/>	
<c:set var="plugin_inFieldLabel" value="true" scope="request"/>
<script type="text/javascript">
$j(document).ready(function () {
	__FMTExtend = {
		stockNotify_add_success:"<fmt:message key="stockNotify.add.success" />",
		stockNotify_add_wait:"<fmt:message key="stockNotify.add.wait" />"
	};
	$j.extend(__FMT, __FMTExtend); 	

	applyValidate($("customerName"),"required,maxlength=30");
	applyValidate($("email"),"required,maxlength=60,email");
	applyValidate($("memo"),"required,maxlength=200");
	
	$j('label[for="memo"]').inFieldLabels();
});
//发送缺货通知
function addStockNotify(){
	if(validateForm($('stockNotifyForm'))){
		$j("#commitButton").html("<i class='loading'>"+__FMT.stockNotify_add_wait+"</i>");
		var postData = $j('#stockNotifyForm :input').serializeArray();
		$j.post(__ctxPath+'/stock-notify/item.html?doAction=addStockNotify',postData,addStockNotifyCallback);
	}else{
		alert(__vaMsg.notPass);
	}		
}
//发送缺货通知callback
function addStockNotifyCallback(){
	alert(__FMT.stockNotify_add_success);
	window.location = $('url').value;
}
</script>